package com.love.web.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("user")
public class UserController {

	@RequestMapping("/register")
	public @ResponseBody Map<String, String> register(HttpServletRequest request, HttpServletResponse response){
		request.getSession().setAttribute("a", "a");
		Map<String, String> responseMap = new HashMap<String, String>();
		responseMap.put("code", "0");
		responseMap.put("msg", "ok");
		return responseMap;
	}
	
	@RequestMapping("/login")
	public @ResponseBody Map<String, String> login(HttpServletRequest request, HttpServletResponse response){
		Map<String, String> responseMap = new HashMap<String, String>();
		responseMap.put("code", "0");
		responseMap.put("msg", "ok");
		responseMap.put("data", (String)request.getSession().getAttribute("a"));
		return responseMap;
	}
	
}
